<?php

declare(strict_types=1);

namespace App\CustHub\Model;

use Mine\MineModel;

/**
 * @property int $id 
 * @property int $tag_id 
 * @property int $contact_id 客户ID
 * @property int $robot_id 机器人ID
 * @property int $type 类型：0=收到 1=自动
 * @property string $created_at 变更时间
 * @property-read null|ChContact $contact 
 * @property-read null|ChRobot $robot 
 * @property-read null|ChSmartTag $tag 
 */
class ChSmartTagChangeLog extends MineModel
{
    public bool $timestamps = false;
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'ch_smart_tag_change_log';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'tag_id', 'contact_id', 'robot_id', 'type', 'created_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'tag_id' => 'integer', 'contact_id' => 'integer', 'robot_id' => 'integer', 'type' => 'integer'];

    /**
     * 联系人
     * @return \Hyperf\Database\Model\Relations\HasOne
     */
    public function contact(): \Hyperf\Database\Model\Relations\HasOne
    {
        return $this->hasOne(ChContact::class, 'id', 'contact_id');
    }

    /**
     * 机器人
     * @return \Hyperf\Database\Model\Relations\HasOne
     */
    public function robot(): \Hyperf\Database\Model\Relations\HasOne
    {
        return $this->hasOne(ChRobot::class, 'id', 'robot_id');
    }

    /**
     * 标签
     * @return \Hyperf\Database\Model\Relations\HasOne
     */
    public function tag(): \Hyperf\Database\Model\Relations\HasOne
    {
        return $this->hasOne(ChSmartTag::class, 'id', 'tag_id');
    }
}
